# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=git-metafile
pkgver=0.2.3
pkgrel=1
pkgdesc="Store and restore files metadata in a git repository"
url="https://github.com/jirutka/git-metafile"
# ppc64le, s390x - fails to build
arch="all !ppc64le !s390x"
license="MIT"
depends="git"
makedepends="cargo rust cargo-auditable"
source="https://github.com/jirutka/git-metafile/archive/v$pkgver/git-metafile-$pkgver.tar.gz
	post-checkout
	pre-commit
	git-etc-init
	gitignore
	"

prepare() {
	default_prepare

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --frozen --release
}

check() {
	./target/release/git-metafile --version
}

package() {
	local sharedir="$pkgdir/usr/share/$pkgname"

	install -D -m 755 target/release/git-metafile "$pkgdir"/usr/bin/git-metafile

	cd "$pkgdir"

	install -D -m 755 "$srcdir"/git-etc-init usr/sbin/git-etc-init

	install -D -m 644 "$srcdir"/gitignore "$sharedir"/gitignore
	install -D -m 755 "$srcdir"/pre-commit "$sharedir"/hooks/pre-commit
	install -D -m 755 "$srcdir"/post-checkout "$sharedir"/hooks/post-checkout
	ln -s post-checkout "$sharedir"/hooks/post-rewrite
}

sha512sums="
147568fecd48c9e8a68777792db70c0f7b50aaa0c9d766f96cb22c7ed8f49861212c399abfc9be65e95fa341dabe6ae2bb567eb5e77a74a69db2183d0ad00e2a  git-metafile-0.2.3.tar.gz
4bd2120071e11a8e9005491ad13ef9065cdb295eed11c3d168d511b93e3acabafc47f07b3463dd14ecd7147d41ce24dcc58eee2131c5656e8f2036eb4ab907f2  post-checkout
af36b28793d94e0c4d73020e50346ee3dcc981082b8304a2e224207ed5c0ea6ea8a4c59e2160f20f4d08e1d94104ee102f32d07d75f96ff88454f2fecb49a074  pre-commit
b45f9adf07bfbde958b7bdb8bfa18c18ee1d67110d8a1228c020a94cdcf8bd72e1e85714529968de6dc1a49016b5b31c30c3aff9fbcc1b6d9ccc8bf175369bce  git-etc-init
35edd88ec44f3eaadd64cb324e33f443295bf48c32b280f8aaae103c1c00df9d801c277c3987d19dbd5c71893a0504862f4f724251d81d1c404147d7d7c31abe  gitignore
"
